/**
 * This is the router for all of the request from clients
 * It will do:
 * (1) audit the request data ;
 * (2) save the request data;
 */

module.exports = function (app) {
    logger.debug("load the filter-route module....");
    var preprocess = require('../filters/preprocess-filter');
    var requestToken = require('../filters/token-filter');
    var requestAudit = require('../filters/audit-filter');
    var requestSave = require('../filters/requestSave-filter');
    var md5Validate = require('../filters/md5Validate-filter');
    var urlParser= require('../filters/url-filter');
    var backOffice= require('../filters/backOffice-filter');

    app.all('/rest/' + RESTFullServiceVersion + '/*', md5Validate.md5Validate, preprocess.preprocess, requestToken.doCheckToken, requestAudit.doAuditRequest, requestSave.doSaveRequest, urlParser.doParser );
    app.all('/rest/' + RESTFullServiceVersion + '/backoffice/*', backOffice.saveBehavior);
    app.all('/rest/' + RESTFullServiceVersion + '/backoffice/*', backOffice.checkAuth);
}
